package com.yunjian.common.utils;

import java.util.Random;

public class RandomUtil {

    /**
     * 生成随机码
     * @param lenth 长度
     * @return 指定长度的随机码
     */
    public static String random(int lenth) {
        StringBuffer output = new StringBuffer();
        // 1和l区分不了，所以不要1
        String a = "234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
        while (output.length() < lenth) {
            output.append(a.charAt(new Random().nextInt(a.length())));
        }
        return output.toString();
    }
}
